﻿<!--ColorPicker, Copyright Mirosław M. Mączka.  All Rights Reserved. This code released under the terms of the Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) -->
<Window x:Class="ColorPicker.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        x:Name="window1"
        Title="Color Picker for C# and XAML" Height="350" Width="514" Loaded="Window_Loaded_1" Background="DarkGray" Icon="colorpicker.ico" Closed="window1_Closed">
    <Window.Resources>

        <sys:Double x:Key="buttonSide">30</sys:Double>

        <Image x:Key="cAnalogous"  Source="cAnalogous.gif" />
        <Image x:Key="cComplementary"  Source="cComplementary.gif" />
        <Image x:Key="cMonochrome"  Source="cMonochrome.gif" />
        <Image x:Key="cSplitComplementary"  Source="cSplitComplementary.gif" />
        <Image x:Key="cSquare"  Source="cSquare.gif" />
        <Image x:Key="cTetradic"  Source="cTetradic.gif" />
        <Image x:Key="cTriadic"  Source="cTriadic.gif" />

        <!--
        <Style x:Name="buttonStyle" TargetType="Button">
            <Setter Property="Width" Value="{StaticResource buttonSide}"/>
            <Setter Property="Height" Value="{StaticResource buttonSide}"/>
            <Setter Property="FontWeight" Value="ExtraBold"/>
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="BorderBrush" Value="Black" />
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="Focusable" Value="False" />
            <Setter Property="FocusManager.IsFocusScope" Value="False" />
        </Style>
        -->
        <!--
        <Style x:Name="textBlockStyle" TargetType="TextBox">
            <Setter Property="Width" Value="{StaticResource buttonSide}"/>
            <Setter Property="Height" Value="{StaticResource buttonSide}"/>
            <Setter Property="Cursor" Value="Arrow"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="BorderBrush" Value="Black" />
            <Setter Property="IsReadOnly" Value="True"/>
        </Style>
        -->
        <Style TargetType="MenuItem">
            <Style.Resources>
                <Style TargetType="Image">
                    <Setter Property="Height" Value="16" />
                    <Setter Property="Width" Value="16" />
                </Style>
            </Style.Resources>
        </Style>
        
            <ContextMenu x:Key="ButtonContextMenu">
            <MenuItem Header="C# code" Click="MenuItem_CS_Click"/>
            <MenuItem Header="XAML Color definition" Click="MenuItem_XAML_Color_Click"/>
            <MenuItem Header="XAML Brush definition" Click="MenuItem_XAML_Brush_Click"/>
            <MenuItem Header="HTML Color definition" Click="MenuItem_HTML_Color_Click"/>
            <Separator/>
            <MenuItem Header="XAML Complement Color" Icon="{StaticResource cComplementary}" Click="MenuItem_XAML_Complement_Click"/>
            <MenuItem Header="XAML Monochrome Color" Icon="{StaticResource cMonochrome}" Click="MenuItem_XAML_Monochrome_Click"/>
            <MenuItem Header="XAML Triadic Colors" Icon="{StaticResource cTriadic}" Click="MenuItem_XAML_Triadic_Click"/>
            <MenuItem Header="XAML Analogous Color" Icon="{StaticResource cAnalogous}" Click="MenuItem_XAML_Analogous_Click"/>
            <MenuItem Header="XAML Split Complements Color" Icon="{StaticResource cSplitComplementary}" Click="MenuItem_XAML_Split_Complements_Click"/>
        </ContextMenu>


    </Window.Resources>

    <Grid Name="grid1">
        <Grid.RowDefinitions>
            <RowDefinition x:Name="message" Height="60" />
            <RowDefinition x:Name="buttons" />
        </Grid.RowDefinitions>
        
        
        <StackPanel Grid.Row="0" FlowDirection="LeftToRight" Orientation="Vertical" CanHorizontallyScroll="False" CanVerticallyScroll="False">
            <StackPanel FlowDirection="LeftToRight" Orientation="Horizontal" CanHorizontallyScroll="False" CanVerticallyScroll="False">


            <Label Background="Black" Foreground="AntiqueWhite" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
               HorizontalContentAlignment="Left"
               VerticalContentAlignment="Center"
               FontSize="12"
               >
                <Label.Content>
                    <TextBlock>
                        <Run FontSize="14" Foreground="Blue" Background="Yellow">Click</Run> Copy to Clipoard C# code, 
                        <Run FontSize="14" Foreground="Blue" Background="Yellow"> Click+Shift</Run> XAML Color definition, 
                        <Run FontSize="14" Foreground="Blue" Background="Yellow"> Click+Control</Run> XAML Brush definition 
                        <Run FontSize="14" Foreground="Blue" Background="Yellow"> Click+Alt</Run> HTML Color definition 
                        </TextBlock>
                </Label.Content>
            </Label>
            </StackPanel>
            <StackPanel FlowDirection="LeftToRight" Orientation="Horizontal" CanHorizontallyScroll="False" CanVerticallyScroll="False">
                <ComboBox x:Name="colorKind" FontSize="16" FontWeight="Bold" Background="Gold" Margin="0,1,0,0" ToolTip="Color Conversion">
                    <ComboBoxItem Content=""  ToolTip="Color As usual" IsSelected="True"/>
                    <ComboBoxItem>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="cComplementary.gif" Height="30"></Image>
                            <TextBlock Text="~"></TextBlock>
                        </StackPanel>
                        <ComboBoxItem.ToolTip>
                            <StackPanel Orientation="Vertical">
                                <Image Source="cComplementary.gif"></Image>
                                <TextBlock Text="Complement Color"></TextBlock>
                            </StackPanel>
                            </ComboBoxItem.ToolTip>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="cMonochrome.gif" Height="30"></Image>
                            <TextBlock Text="BW"></TextBlock>
                        </StackPanel>
                        <ComboBoxItem.ToolTip>
                            <StackPanel Orientation="Vertical">
                                <Image Source="cMonochrome.gif"></Image>
                                <TextBlock Text="Monochrome Color"></TextBlock>
                            </StackPanel>
                        </ComboBoxItem.ToolTip>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="cTriadic.gif" Height="30"></Image>
                            <TextBlock Text="T"></TextBlock>
                        </StackPanel>
                        <ComboBoxItem.ToolTip>
                            <StackPanel Orientation="Vertical">
                                <Image Source="cTriadic.gif"></Image>
                                <TextBlock Text="Triadic Colors"></TextBlock>
                            </StackPanel>
                        </ComboBoxItem.ToolTip>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="cAnalogous.gif" Height="30"></Image>
                            <TextBlock Text="A"></TextBlock>
                        </StackPanel>
                        <ComboBoxItem.ToolTip>
                            <StackPanel Orientation="Vertical">
                                <Image Source="cAnalogous.gif"></Image>
                                <TextBlock Text="Analogous Colors"></TextBlock>
                            </StackPanel>
                        </ComboBoxItem.ToolTip>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="cSplitComplementary.gif" Height="30"></Image>
                            <TextBlock Text="SC"></TextBlock>
                        </StackPanel>
                        <ComboBoxItem.ToolTip>
                            <StackPanel Orientation="Vertical">
                                <Image Source="cSplitComplementary.gif"></Image>
                                <TextBlock Text="Split Complements Colors"></TextBlock>
                            </StackPanel>
                        </ComboBoxItem.ToolTip>
                    </ComboBoxItem>
                </ComboBox>

                <Button  x:Name="gradientButton" Background="Chartreuse" Foreground="Black" Content="Begin Gradient" Margin="2" Height="Auto" Width="Auto"  Click="Button_Click_1"
                                         FontWeight="ExtraBold"
                BorderThickness="1"
                BorderBrush="Black"
                Focusable="False"
                         >
                    <Button.ToolTip>
                        <StackPanel>
                            <TextBlock>
                            <Run xml:space='preserve'>Push   </Run><Run Foreground="Black" Background="Chartreuse">Begin Gradient</Run>>
                            </TextBlock>
                            <TextBlock>Click Colors</TextBlock>
                            <TextBlock>
                            <Run xml:space='preserve'>Push   </Run><Run Foreground="Black" Background="HotPink">End Gradient</Run>>
                            </TextBlock>
                        </StackPanel>
                    </Button.ToolTip>
                </Button>
                <ComboBox x:Name="gradientKind" FontSize="16" FontWeight="Bold" Background="LightSkyBlue" Margin="0,1,0,0" ToolTip="Kind of Gradient">
                <ComboBoxItem Content=" → "  FontSize="20" FontWeight="ExtraBold" ToolTip="Horizontal" IsSelected="True"/>
                    <ComboBoxItem Content=" ↓ " FontSize="20" FontWeight="ExtraBold" ToolTip="Vertical"/>
                    <ComboBoxItem Content=" ↘ " FontSize="20" FontWeight="ExtraBold" ToolTip="Diagonal ↘"/>
                    <ComboBoxItem Content=" ↗ " FontSize="20" FontWeight="ExtraBold" ToolTip="Diagonal ↗"/>
                    <ComboBoxItem Content=" ❍ " FontSize="20" FontWeight="ExtraBold" ToolTip="Radial ❍"/>
            </ComboBox>
                <Label Margin="20,1,0,0" FontWeight="ExtraBold" FontSize="16">Search:</Label>
            <TextBox x:Name="textSearch" Text="" Width="200" Margin="2,1,0,0" FontSize="18" PreviewKeyDown="textSearch_PreviewKeyDown" Cursor="IBeam" ForceCursor="True">
                    <TextBox.ToolTip>
                        <StackPanel>
                            <TextBlock>Select colors by name</TextBlock>
                            <TextBlock>ENTER - confirm</TextBlock>
                            <TextBlock>ESC - cancel</TextBlock>
                            <TextBlock>or <Run Foreground="Blue" Background="Yellow">>#hex</Run>- value of color</TextBlock>
                        </StackPanel>
                    </TextBox.ToolTip>
                    </TextBox>
                    <Label Margin="10,4,0,0">
                <TextBlock><Hyperlink NavigateUri="http://mmm777.kilu.de/colors.htm" RequestNavigate="Hyperlink_RequestNavigate_1">Table of Colors</Hyperlink></TextBlock>
            </Label>
            </StackPanel>
            
            
            
        </StackPanel>


        <ScrollViewer Grid.Row="1" x:Name="myScrollViewer" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
            <WrapPanel x:Name="panel1" MinWidth="250"
                       Width="{Binding ElementName=myScrollViewer, Path=ViewportWidth}"
                       HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                       PreviewMouseLeftButtonDown="panel1_PreviewMouseLeftButtonDown_1"
                       />
        </ScrollViewer>
    </Grid>
</Window>
